package main;

import java.net.*;

public abstract class NetworkThread implements Runnable
{
	private byte[] sendData = new byte[1024];

	public abstract void run();

	protected abstract InetAddress getOutgoingIPAddress();

	protected abstract int getOutgoingPort();

	protected void setSendData(String s)
	{
		this.sendData = s.getBytes();
	}

	protected DatagramPacket makeSendPacket()
	{
		// set paramters, create new DatagramPacket
		return new DatagramPacket(sendData, sendData.length,
				getOutgoingIPAddress(), getOutgoingPort());
	}

	protected DatagramPacket makeReceivePacket()
	{
		// construct a new receiver Datagram packet
		return new DatagramPacket(new byte[1024], 1024);
	}

	protected String convertPacketToString(DatagramPacket pkt)
	{
		// construct a string from a Datagram packet
		return new String(pkt.getData());
	}
}
